package edu.qust.service.serviceimpl;

import edu.qust.domain.Book;
import edu.qust.mapper.BookMapper;
import edu.qust.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class IBookService implements BookService {
    @Autowired
    private BookMapper bookMapper;

    @Override
    public List<Book> findAllBook(Book book){
        return bookMapper.findBook(book);
    }

    @Override
    public int deleteBook(Integer id) {
        return bookMapper.deleteBook(id);
    }

    @Override
    public Book selectBook(Book bok) {
        if (bookMapper.findBook(bok).size()>0){
            return bookMapper.findBook(bok).get(0);
        }else {
            return null;
        }
    }

    @Override
    public int editBook(Book book) {
        return bookMapper.editBook(book);
    }

    @Override
    public int addBook(Book book) {
        return bookMapper.addBook(book);
    }
}
